package com.itwn.mapper;

import com.itwn.entity.Schedule;
import com.itwn.vo.ScheduleQueryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
@Repository
public interface ScheduleMapper {
    int deleteByPrimaryKey(Integer scheduleId);

    int insert(Schedule record);

    Schedule selectByPrimaryKey(Integer scheduleId);

    List<Schedule> selectAll();

    int updateByPrimaryKey(Schedule record);

    List<ScheduleQueryVo> selectByPage(@Param("cinemaHallId") int cinemaHallId,
                                       @Param("movieName") String movieName,
                                       @Param("startTime") Date startTime,
                                       @Param("endTime") Date endTime);

    @Update("update c_schedule set schedule_state='0' where schedule_id=#{scheduleId}")
    int updateState(Integer scheduleId);

    int isRepeated(@Param("cinemaHallId") Integer cinemaHallId,
                   @Param("movieId") Integer movieId,
                   @Param("startTime") Date startTime,
                   @Param("endTime") Date endTime);

    int isRepeatedForUpdate(@Param("cinemaHallId") int cinemaHallId,
                            @Param("startTime") Date startTime,
                            @Param("endTime") Date endTime);
}